Ext.define('AmpleHarvest.objects.search.template.cReaperDisplay',
{
	extend			: 'Ext.XTemplate',
	statics			:
	{
		C_STR_FIELD_PUBLISH_DATE	: "publish_date",
		C_STR_FIELD_HARVEST_DATE	: "harvest_date",
		C_STR_FIELD_INDEX_DATE		: "index_date",
		C_STR_FIELD_SCORE			: "score",
		C_STR_FIELD_CONTENT			: "content",
		C_STR_FIELD_ID				: "id",
		C_STR_FIELD_TITLE			: "title",
		C_STR_FIELD_SUMMARY			: "summary"

	},
	m_arr_Fields	: [],
	perPage			: 10,
	type			: "template",

	constructor		: function(str_HTML)
	{
		this.m_arr_Fields =
		[
				this.self.C_STR_FIELD_PUBLISH_DATE,
				this.self.C_STR_FIELD_HARVEST_DATE,
				this.self.C_STR_FIELD_INDEX_DATE, this.self.C_STR_FIELD_SCORE,
				this.self.C_STR_FIELD_CONTENT, this.self.C_STR_FIELD_ID,
				this.self.C_STR_FIELD_TITLE, this.self.C_STR_FIELD_SUMMARY
		];

		this
				.callParent(
						[
								'<b>{query}</b>'+
								'<p>{' + this.self.C_STR_FIELD_SUMMARY
										+ '}</p>',
								'<label>Publish Date</label> : {'
										+ this.self.C_STR_FIELD_PUBLISH_DATE
										+ '}<br/>',

								'<label>Harvest Date</label> : {'
										+ this.self.C_STR_FIELD_HARVEST_DATE
										+ '}<br/>',
								'<label>Index Date</label> : {'
										+ this.self.C_STR_FIELD_INDEX_DATE
										+ '}<br/>',
								'<label>Score</label> : {'
										+ this.self.C_STR_FIELD_SCORE
										+ '}<br/>',
								'<tpl if="highlight">',
								'<div class="results">',
								'<h4>Results</h4>',
								'<tpl for="this.get_Highlight(highlight)">',

								'<tpl for=".">',
								'<div class="field">',
								'<label>{name}</label> - {data}',
								'</div>',
								'</tpl>',

								'</tpl>',
								'</div>',
								'</tpl>',
								//'<label>Link</label> : <span class = "link" ',
								//'onclick="m_obj_AmpleHarvest_ViewPort.fireEvent(AmpleHarvest.eventHandler.cWindowEvents.C_STR_EVENT_ARTICLE_OPEN,\'{'
								//		+ this.self.C_STR_FIELD_ID + '}\');">',
								//'{title}</span>',
								{
									get_Highlight	: function(obj_Highlight)
									{
										var arr_Output = [];
										for (key in obj_Highlight)
										{
											var obj_HighlightOut = new Object();
											var str_Data = "";
											for (int_Find in obj_Highlight[key])
											{
												str_Data += obj_Highlight[key][int_Find];
											}
											str_Data = str_Data.replace("<em>",
													"!@#$RAB$#@!"
											);
											str_Data = str_Data.replace(
													"</em>", "$#@!RAB!@#$"
											);
											str_Data = str_Data.replace(
													/(<([^>]+)>)/ig, ""
											);
											str_Data = str_Data.replace(
													"!@#$RAB$#@!", "<em>"
											);
											str_Data = str_Data.replace(
													"$#@!RAB!@#$", "</em>"
											);
											obj_HighlightOut.name = key;
											obj_HighlightOut.data = str_Data;
											arr_Output.push(obj_HighlightOut);
										}
										return arr_Output;
									}
								}
						]
				);
	}
}
);
